package com.yeswater.multithread.chapter2.test2_1.test6;

/**
 * author : yeswater
 * date : 2023/10/19
 */

public class PublicVar {

    private String username = "A";
    private String password = "AA";

    synchronized public void setValue(String username, String password) {
        this.username = username;
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        this.password = password;

        System.out.println("setValue method thread name = " + Thread.currentThread().getName()
                + " username = " + username
                + " password = " + password);
    }

    synchronized public void getValue() {
        System.out.println("getValue method thread name = " + Thread.currentThread().getName()
                + " username = " + username
                + " password = " + password);
    }

}
